package week3;

import java.util.ArrayList;
import java.util.List;

public class Ex26 {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();
        int temp;
        int ans = 0;
        int max = 0;
        for (int i = 2; i < 1000; ++i){
            list.clear();
            temp = 1 % i;
            while (!list.contains(temp)){
                if (temp == 0) break;
                list.add(temp);
                temp *= 10;
                temp = temp % i;
            }
            if (temp != 0){
                if (max < list.size() - list.indexOf(temp)) {
                    max = list.size() - list.indexOf(temp);
                    ans = i;
                }
            }
        }
        System.out.println(ans);
    }
}
